#include <cstdio>
#include <cstdlib>

typedef long long ll;
const int N = 2000005, mod = 1e9 + 7;
char s[N];
ll z[N], Z[N];
int n, k, q, l, r, ans;
int a[N], b[N], c[N], d[N];

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("Tiramisu.in", "r", stdin);
  freopen("Tiramisu.out", "w", stdout);
#endif
#endif
  scanf("%d%d%d%s", &n, &k, &q, s + 1);
  srand((unsigned long long)new char);
  for (int i = 0; i < k; i++) z[i] = 1ll * rand() % mod * rand() % mod;
  for (int i = 1; i <= n; i++) {
    a[i] = a[i - 1];
    Z[i] = Z[i - 1];
    if ((s[i] -= '0') ^ s[i - 1]) {
      Z[i] ^= z[i % k];
      a[i] -= b[i % k];
      b[i % k] = i / k - b[i % k];
      a[i] += b[i % k];
    }
    c[i] = b[(i + 1) % k];
    d[i] = b[i % k];
  }
  while (q--) {
    scanf("%d%d", &l, &r);
    if (Z[r] ^ Z[l] ^ (s[r] * z[(r + 1) % k]) ^ (s[l] * z[l % k])) {
      puts("-1");
      continue;
    }
    ans = a[r] - a[l];
    if (s[r]) ans += (r + 1) / k - 2 * c[r];
    if (s[l]) ans += 2 * d[l] - l / k;
    printf("%d\n", ans);
  }
}